Skip to content

HDDS-13943. Improve error message for malformed input in DirstreamClientHandler#9316

Merged
adoroszlai merged 8 commits intoapache:masterfrom
rich7420:HDDS-13943
Nov 19, 2025
Merged

HDDS-13943. Improve error message for malformed input in DirstreamClientHandler#9316
adoroszlai merged 8 commits intoapache:masterfrom
rich7420:HDDS-13943

Conversation

@rich7420
Copy link
Contributor

What changes were proposed in this pull request?

This PR added input validation for protocol format in DirstreamClientHandler to prevent ArrayIndexOutOfBoundsException. At the same time , this PR added tests for the situation.

What is the link to the Apache JIRA

HDDS-13943

How was this patch tested?

https://github.com/rich7420/ozone/actions/runs/19432005403

@Gargi-jais11
Copy link
Contributor

Thanks @rich7420 for working on this. Left some comments above.

Your current test only checks if space is missing or there is an empty file name. Can you please also test the below scenario where the size isn't a number.
Input: "oops filename.txt"
Code Behaviour: parts.length is 2 (Pass), but Long.parseLong(parts[0]) will crash with NumberFormatException.

This ensure that if the size is bad, the application handles it correctly.

…ozone/container/stream/DirstreamClientHandler.java

Co-authored-by: Gargi Jaiswal <134698352+Gargi-jais11@users.noreply.github.com>
@rich7420
Copy link
Contributor Author

@Gargi-jais11 thanks for the review! I'll try to complete what you suggested as soon as possible.

Copy link
Contributor

@sarvekshayr sarvekshayr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rich7420 for working on this.

We can parameterize the test and pass in the different invalid strings we want to validate. Also, renaming the method to something more generic like testInvalidFormat would help reduce code duplication.

@rich7420
Copy link
Contributor Author

@sarvekshayr thanks for the review! I'll try it!

@rich7420
Copy link
Contributor Author

thanks @sarvekshayr ! I've modified it.

@rich7420
Copy link
Contributor Author

@adoroszlai thanks for the suggestion!

@adoroszlai adoroszlai changed the title HDDS-13943. Add input validation for protocol format in DirstreamClientHandler to prevent ArrayIndexOutOfBoundsException HDDS-13943. Improve error message for malformed input in DirstreamClientHandler Nov 18, 2025
Copy link
Contributor

@sarvekshayr sarvekshayr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch LGTM !

@adoroszlai adoroszlai merged commit e51a88b into apache:master Nov 19, 2025
44 checks passed
@adoroszlai
Copy link
Contributor

Thanks @rich7420 for the patch, @Gargi-jais11, @sarvekshayr for the review.

@rich7420
Copy link
Contributor Author

Thanks!!! @Gargi-jais11 , @sarvekshayr and @adoroszlai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants